﻿using SuperJoe.Framwork.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WWX.Admin.BLL;
using WWX.Admin.Web.Models;
using WWX.Dto.Search;

namespace WWX.Admin.Web.Controllers
{
    public class RechargeController : AuthorizationController
    {
        public ActionResult Index()
        {
            return View();
        }

        public JsonResult List(RechargeAdminSearch search, int limit, int pageIndex = 0)
        {
            int results = 0;
            var list = new RechargeBLL().GetPageList(search, ++pageIndex, limit, out results);
            return this.Json(new { results, rows = list.Select(l => new { no = l.No, account = l.MemberAccount, nickName = l.MemberNickName, trueName = l.MemberTrueName, phone = l.MemberPhone, amount = l.Amount, zamount = l.ZAmount, date = l.Date.ToString(), remark = l.Remark }) }, JsonRequestBehavior.AllowGet);
        }

        public JsonResult Save(RechargeVM vm)
        {
            var bll = new RechargeBLL();
            bll.Add(vm.ToRechargeSaveDto());

            return this.CreateRichJsonResult();
        }
    }
}